package org.kalai.unifypay.zhongxpay;

import java.util.Map;

import org.kalai.unifypay.Constant;
import org.kalai.unifypay.util.CipherUtils;

public class ZhongxUtil {
	public static String getMd5Sign(Map<String, Object> params){
		StringBuffer sbf = new StringBuffer();
		for (Map.Entry<String, Object> entry : params.entrySet()) {
			sbf.append(entry.getKey()).append("=").append(entry.getValue()).append("&");
		}
		sbf.append("key=").append(Constant.ZX_MCHSECRET);
		System.out.println(sbf);
		return CipherUtils.encryptMD5(sbf.toString());
	}

	public static String getXmlData(Map<String, Object> params) {
		StringBuffer sbf = new StringBuffer("<xml>");
		for (Map.Entry<String, Object> entry : params.entrySet()) {
			sbf.append("<").append(entry.getKey()).append(">")
				.append(entry.getValue())
				.append("</").append(entry.getKey()).append(">");
		}
		sbf.append("</xml>");
		System.out.println(sbf.toString());
		return sbf.toString();
	}
}
